//
//  BONCPresentViewController.m
//  TestMe
//
//  Created by HePing on 14-9-25.
//  Copyright (c) 2014年 HePing. All rights reserved.
//

#import "BONCPresentViewController.h"

@implementation BONCPresentViewController

- (void)viewDidLoad
{
    UIButton* promote=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    promote.frame=CGRectMake(0, 0, 100, 80);
    self.view.backgroundColor=[UIColor colorWithWhite:1.0 alpha:0.4];
    promote.center=CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2+100);
    [promote setTitle:@"Go Back" forState:UIControlStateNormal];
    [promote setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [promote addTarget:self action:@selector(getBack:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:promote];
}

- (void)getBack:(id)sender
{
    CATransition *animation = [CATransition animation];
    animation.duration = 2.0;
    animation.delegate=self;
    animation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    animation.type =kCATransitionReveal;
    animation.subtype = kCATransitionFromLeft;
    self.view.hidden=YES;
    [self.view.layer addAnimation:animation forKey:@"MoveInFromRight"];
}

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
    [self dismissViewControllerAnimated:NO completion:nil];
}
@end
